package cc.prayol.permission.mapper.auth;

import static cc.prayol.permission.mapper.auth.GenTableColumnDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import cc.prayol.permission.entity.auth.GenTableColumn;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface GenTableColumnMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.577+08:00", comments="Source Table: gen_table_column")
    BasicColumn[] selectList = BasicColumn.columnList(columnId, tableId, columnName, columnComment, columnType, javaType, javaField, isPk, isIncrement, isRequired, isInsert, isEdit, isList, isQuery, queryType, htmlType, dictType, sort, createBy, createTime, updateBy, updateTime);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.576+08:00", comments="Source Table: gen_table_column")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.576+08:00", comments="Source Table: gen_table_column")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.576+08:00", comments="Source Table: gen_table_column")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<GenTableColumn> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.576+08:00", comments="Source Table: gen_table_column")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("GenTableColumnResult")
    Optional<GenTableColumn> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.576+08:00", comments="Source Table: gen_table_column")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="GenTableColumnResult", value = {
        @Result(column="column_id", property="columnId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="table_id", property="tableId", jdbcType=JdbcType.VARCHAR),
        @Result(column="column_name", property="columnName", jdbcType=JdbcType.VARCHAR),
        @Result(column="column_comment", property="columnComment", jdbcType=JdbcType.VARCHAR),
        @Result(column="column_type", property="columnType", jdbcType=JdbcType.VARCHAR),
        @Result(column="java_type", property="javaType", jdbcType=JdbcType.VARCHAR),
        @Result(column="java_field", property="javaField", jdbcType=JdbcType.VARCHAR),
        @Result(column="is_pk", property="isPk", jdbcType=JdbcType.CHAR),
        @Result(column="is_increment", property="isIncrement", jdbcType=JdbcType.CHAR),
        @Result(column="is_required", property="isRequired", jdbcType=JdbcType.CHAR),
        @Result(column="is_insert", property="isInsert", jdbcType=JdbcType.CHAR),
        @Result(column="is_edit", property="isEdit", jdbcType=JdbcType.CHAR),
        @Result(column="is_list", property="isList", jdbcType=JdbcType.CHAR),
        @Result(column="is_query", property="isQuery", jdbcType=JdbcType.CHAR),
        @Result(column="query_type", property="queryType", jdbcType=JdbcType.VARCHAR),
        @Result(column="html_type", property="htmlType", jdbcType=JdbcType.VARCHAR),
        @Result(column="dict_type", property="dictType", jdbcType=JdbcType.VARCHAR),
        @Result(column="sort", property="sort", jdbcType=JdbcType.INTEGER),
        @Result(column="create_by", property="createBy", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="update_by", property="updateBy", jdbcType=JdbcType.VARCHAR),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<GenTableColumn> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.576+08:00", comments="Source Table: gen_table_column")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.576+08:00", comments="Source Table: gen_table_column")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, genTableColumn, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.576+08:00", comments="Source Table: gen_table_column")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, genTableColumn, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.576+08:00", comments="Source Table: gen_table_column")
    default int deleteByPrimaryKey(Long columnId_) {
        return delete(c -> 
            c.where(columnId, isEqualTo(columnId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.576+08:00", comments="Source Table: gen_table_column")
    default int insert(GenTableColumn record) {
        return MyBatis3Utils.insert(this::insert, record, genTableColumn, c ->
            c.map(columnId).toProperty("columnId")
            .map(tableId).toProperty("tableId")
            .map(columnName).toProperty("columnName")
            .map(columnComment).toProperty("columnComment")
            .map(columnType).toProperty("columnType")
            .map(javaType).toProperty("javaType")
            .map(javaField).toProperty("javaField")
            .map(isPk).toProperty("isPk")
            .map(isIncrement).toProperty("isIncrement")
            .map(isRequired).toProperty("isRequired")
            .map(isInsert).toProperty("isInsert")
            .map(isEdit).toProperty("isEdit")
            .map(isList).toProperty("isList")
            .map(isQuery).toProperty("isQuery")
            .map(queryType).toProperty("queryType")
            .map(htmlType).toProperty("htmlType")
            .map(dictType).toProperty("dictType")
            .map(sort).toProperty("sort")
            .map(createBy).toProperty("createBy")
            .map(createTime).toProperty("createTime")
            .map(updateBy).toProperty("updateBy")
            .map(updateTime).toProperty("updateTime")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.576+08:00", comments="Source Table: gen_table_column")
    default int insertSelective(GenTableColumn record) {
        return MyBatis3Utils.insert(this::insert, record, genTableColumn, c ->
            c.map(columnId).toPropertyWhenPresent("columnId", record::getColumnId)
            .map(tableId).toPropertyWhenPresent("tableId", record::getTableId)
            .map(columnName).toPropertyWhenPresent("columnName", record::getColumnName)
            .map(columnComment).toPropertyWhenPresent("columnComment", record::getColumnComment)
            .map(columnType).toPropertyWhenPresent("columnType", record::getColumnType)
            .map(javaType).toPropertyWhenPresent("javaType", record::getJavaType)
            .map(javaField).toPropertyWhenPresent("javaField", record::getJavaField)
            .map(isPk).toPropertyWhenPresent("isPk", record::getIsPk)
            .map(isIncrement).toPropertyWhenPresent("isIncrement", record::getIsIncrement)
            .map(isRequired).toPropertyWhenPresent("isRequired", record::getIsRequired)
            .map(isInsert).toPropertyWhenPresent("isInsert", record::getIsInsert)
            .map(isEdit).toPropertyWhenPresent("isEdit", record::getIsEdit)
            .map(isList).toPropertyWhenPresent("isList", record::getIsList)
            .map(isQuery).toPropertyWhenPresent("isQuery", record::getIsQuery)
            .map(queryType).toPropertyWhenPresent("queryType", record::getQueryType)
            .map(htmlType).toPropertyWhenPresent("htmlType", record::getHtmlType)
            .map(dictType).toPropertyWhenPresent("dictType", record::getDictType)
            .map(sort).toPropertyWhenPresent("sort", record::getSort)
            .map(createBy).toPropertyWhenPresent("createBy", record::getCreateBy)
            .map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
            .map(updateBy).toPropertyWhenPresent("updateBy", record::getUpdateBy)
            .map(updateTime).toPropertyWhenPresent("updateTime", record::getUpdateTime)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.577+08:00", comments="Source Table: gen_table_column")
    default Optional<GenTableColumn> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, genTableColumn, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.577+08:00", comments="Source Table: gen_table_column")
    default List<GenTableColumn> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, genTableColumn, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.577+08:00", comments="Source Table: gen_table_column")
    default List<GenTableColumn> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, genTableColumn, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.577+08:00", comments="Source Table: gen_table_column")
    default Optional<GenTableColumn> selectByPrimaryKey(Long columnId_) {
        return selectOne(c ->
            c.where(columnId, isEqualTo(columnId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.577+08:00", comments="Source Table: gen_table_column")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, genTableColumn, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.577+08:00", comments="Source Table: gen_table_column")
    static UpdateDSL<UpdateModel> updateAllColumns(GenTableColumn record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(columnId).equalTo(record::getColumnId)
                .set(tableId).equalTo(record::getTableId)
                .set(columnName).equalTo(record::getColumnName)
                .set(columnComment).equalTo(record::getColumnComment)
                .set(columnType).equalTo(record::getColumnType)
                .set(javaType).equalTo(record::getJavaType)
                .set(javaField).equalTo(record::getJavaField)
                .set(isPk).equalTo(record::getIsPk)
                .set(isIncrement).equalTo(record::getIsIncrement)
                .set(isRequired).equalTo(record::getIsRequired)
                .set(isInsert).equalTo(record::getIsInsert)
                .set(isEdit).equalTo(record::getIsEdit)
                .set(isList).equalTo(record::getIsList)
                .set(isQuery).equalTo(record::getIsQuery)
                .set(queryType).equalTo(record::getQueryType)
                .set(htmlType).equalTo(record::getHtmlType)
                .set(dictType).equalTo(record::getDictType)
                .set(sort).equalTo(record::getSort)
                .set(createBy).equalTo(record::getCreateBy)
                .set(createTime).equalTo(record::getCreateTime)
                .set(updateBy).equalTo(record::getUpdateBy)
                .set(updateTime).equalTo(record::getUpdateTime);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.577+08:00", comments="Source Table: gen_table_column")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(GenTableColumn record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(columnId).equalToWhenPresent(record::getColumnId)
                .set(tableId).equalToWhenPresent(record::getTableId)
                .set(columnName).equalToWhenPresent(record::getColumnName)
                .set(columnComment).equalToWhenPresent(record::getColumnComment)
                .set(columnType).equalToWhenPresent(record::getColumnType)
                .set(javaType).equalToWhenPresent(record::getJavaType)
                .set(javaField).equalToWhenPresent(record::getJavaField)
                .set(isPk).equalToWhenPresent(record::getIsPk)
                .set(isIncrement).equalToWhenPresent(record::getIsIncrement)
                .set(isRequired).equalToWhenPresent(record::getIsRequired)
                .set(isInsert).equalToWhenPresent(record::getIsInsert)
                .set(isEdit).equalToWhenPresent(record::getIsEdit)
                .set(isList).equalToWhenPresent(record::getIsList)
                .set(isQuery).equalToWhenPresent(record::getIsQuery)
                .set(queryType).equalToWhenPresent(record::getQueryType)
                .set(htmlType).equalToWhenPresent(record::getHtmlType)
                .set(dictType).equalToWhenPresent(record::getDictType)
                .set(sort).equalToWhenPresent(record::getSort)
                .set(createBy).equalToWhenPresent(record::getCreateBy)
                .set(createTime).equalToWhenPresent(record::getCreateTime)
                .set(updateBy).equalToWhenPresent(record::getUpdateBy)
                .set(updateTime).equalToWhenPresent(record::getUpdateTime);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.577+08:00", comments="Source Table: gen_table_column")
    default int updateByPrimaryKey(GenTableColumn record) {
        return update(c ->
            c.set(tableId).equalTo(record::getTableId)
            .set(columnName).equalTo(record::getColumnName)
            .set(columnComment).equalTo(record::getColumnComment)
            .set(columnType).equalTo(record::getColumnType)
            .set(javaType).equalTo(record::getJavaType)
            .set(javaField).equalTo(record::getJavaField)
            .set(isPk).equalTo(record::getIsPk)
            .set(isIncrement).equalTo(record::getIsIncrement)
            .set(isRequired).equalTo(record::getIsRequired)
            .set(isInsert).equalTo(record::getIsInsert)
            .set(isEdit).equalTo(record::getIsEdit)
            .set(isList).equalTo(record::getIsList)
            .set(isQuery).equalTo(record::getIsQuery)
            .set(queryType).equalTo(record::getQueryType)
            .set(htmlType).equalTo(record::getHtmlType)
            .set(dictType).equalTo(record::getDictType)
            .set(sort).equalTo(record::getSort)
            .set(createBy).equalTo(record::getCreateBy)
            .set(createTime).equalTo(record::getCreateTime)
            .set(updateBy).equalTo(record::getUpdateBy)
            .set(updateTime).equalTo(record::getUpdateTime)
            .where(columnId, isEqualTo(record::getColumnId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.577+08:00", comments="Source Table: gen_table_column")
    default int updateByPrimaryKeySelective(GenTableColumn record) {
        return update(c ->
            c.set(tableId).equalToWhenPresent(record::getTableId)
            .set(columnName).equalToWhenPresent(record::getColumnName)
            .set(columnComment).equalToWhenPresent(record::getColumnComment)
            .set(columnType).equalToWhenPresent(record::getColumnType)
            .set(javaType).equalToWhenPresent(record::getJavaType)
            .set(javaField).equalToWhenPresent(record::getJavaField)
            .set(isPk).equalToWhenPresent(record::getIsPk)
            .set(isIncrement).equalToWhenPresent(record::getIsIncrement)
            .set(isRequired).equalToWhenPresent(record::getIsRequired)
            .set(isInsert).equalToWhenPresent(record::getIsInsert)
            .set(isEdit).equalToWhenPresent(record::getIsEdit)
            .set(isList).equalToWhenPresent(record::getIsList)
            .set(isQuery).equalToWhenPresent(record::getIsQuery)
            .set(queryType).equalToWhenPresent(record::getQueryType)
            .set(htmlType).equalToWhenPresent(record::getHtmlType)
            .set(dictType).equalToWhenPresent(record::getDictType)
            .set(sort).equalToWhenPresent(record::getSort)
            .set(createBy).equalToWhenPresent(record::getCreateBy)
            .set(createTime).equalToWhenPresent(record::getCreateTime)
            .set(updateBy).equalToWhenPresent(record::getUpdateBy)
            .set(updateTime).equalToWhenPresent(record::getUpdateTime)
            .where(columnId, isEqualTo(record::getColumnId))
        );
    }
}